import Vue from 'vue'
import Router from 'vue-router'
import Home from './modules/home'
import Mine from './modules/mine.js'
// import HelloWorld from '@/components/HelloWorld'

Vue.use(Router)
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

export default new Router({

  routes: [
    ...Home,
    ...Mine,
    // {
    //   path: '/',
    //   name: 'index',
    //   meta: {
    //     title: '首页',
    //     keepAlive: true //需要缓存
    //   },
    //   component: resolve => {
    //     require(['../views/index.vue'], resolve)
    //   },
    //   // redirect: to => {
    //   //   return '/index'
    //   // }
    // },
    {
      path: '/classify',
      name: 'classify',
      meta: {
        title: '分类',
        keepAlive: false //需要缓存
      },
      component: resolve => {
        require(['../views/classify.vue'], resolve)
      },
    },
    {
      path: '/inventory',
      name: 'inventory',
      meta: {
        title: '必抢清单',
        keepAlive: false //需要缓存
      },
      component: resolve => {
        require(['../views/inventory.vue'], resolve)
      },
    },
    {
      path: '/cart',
      name: 'cart',
      meta: {
        title: '购物车',
        keepAlive: false //需要缓存
      },
      component: resolve => {
        require(['../views/cart.vue'], resolve)
      },
    },
    {
      path: '/search',
      name: 'search',
      meta: {
        title: '搜索',
        keepAlive: false //需要缓存
      },
      component: resolve => {
        require(['../views/search.vue'], resolve)
      },
    },
    {
      path: '/login',
      name: 'login',
      meta: {
        title: '登录',
        keepAlive: false
      },
      component: resolve => {
        require(['../views/login.vue'], resolve)
      },
    },
  ]
})